package domain;

import java.util.Collection;
import java.util.HashSet;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;

@Entity
@Access(AccessType.PROPERTY)
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "userAccount_id" }),
							 @UniqueConstraint(columnNames = { "number" })  })

public class Customer extends Actor {
	
	// Constructors//
	public Customer(){
		super();
		
		orders =  new HashSet<Order>();
		shoppingCartItemUnits = new HashSet<ShoppingCartItemUnit>();
		availableItems = new HashSet<AvailableItem>();
		wishList = new HashSet<AvailableItem>();
		orderedItems = new HashSet<PurchasedItem>();
		
		
		
		
	}
	//Attributes//
		private CreditCard creditCard;
		private String address;
		
	@NotNull
	@Valid
	public CreditCard getCreditCard() {
		return creditCard;
	}
	
	public void setCreditCard(CreditCard creditCard) {
		this.creditCard = creditCard;
	}

	@NotBlank
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
	// Relationships//
	
	private Collection<Order> orders;
	private Collection<ShoppingCartItemUnit> shoppingCartItemUnits;
	private Collection<AvailableItem> availableItems;
	private Collection<AvailableItem> wishList;
	private Collection<PurchasedItem> orderedItems;
	
	@OneToMany(mappedBy = "buyer")
	public Collection<Order> getOrders() {
		return orders;
	}

	public void setOrders(Collection<Order> orders) {
		this.orders = orders;
	}

	@OneToMany(mappedBy = "customer")
	public Collection<ShoppingCartItemUnit> getShoppingCartItemUnits() {
		return shoppingCartItemUnits;
	}

	public void setShoppingCartItemUnits(Collection<ShoppingCartItemUnit> shoppingCartItemUnits) {
		this.shoppingCartItemUnits = shoppingCartItemUnits;
	}

	@OneToMany(mappedBy = "seller")
	public Collection<AvailableItem> getAvailableItems() {
		return availableItems;
	}

	public void setAvailableItems(Collection<AvailableItem> availableItems) {
		this.availableItems = availableItems;
	}

	@ManyToMany
	public Collection<AvailableItem> getWishList() {
		return wishList;
	}

	public void setWishList(Collection<AvailableItem> wishList) {
		this.wishList = wishList;
	}

	@OneToMany(mappedBy = "seller")
	public Collection<PurchasedItem> getOrderedItems() {
		return orderedItems;
	}

	public void setOrderedItems(Collection<PurchasedItem> orderedItems) {
		this.orderedItems = orderedItems;
	}
	
	
	
	
}
